package com.hibernate.table;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.SecondaryTable;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;

import org.apache.commons.collections.functors.FalsePredicate;

@Entity
@Table(name = "CUSTOMER", uniqueConstraints = @UniqueConstraint(columnNames = "name"))
@SecondaryTable(name = "CUSTOMER_DETAILS", uniqueConstraints = @UniqueConstraint(columnNames = "address"))
public class Customer {

	public int id;
	public String name;
	public String address;

	public int size;

	@Id
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	// @Basic(fetch=FetchType.LAZY)
	// FIXME Why Lazy can't and I don't understand : unique it doesn't effect
	@Column(name="name", unique=true, nullable=false, insertable=false, updatable=false)
	// Option of @Column : precision, scale use with decimal number.
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}

	@Column(table = "CUSTOMER_DETAILS")
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Transient
	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}

}
